75A - Life Without Zeros - CodeForces Solution


implementation *1000

Please click on ads to support us..

Python Code:

a = ""
b = ""
a = input()
b = input()
a1 = int(a)
b1 = int(b)
c = a1 + b1
a = a.replace("0", "")
b = b.replace("0", "")
c = str(c)
c = c.replace("0", "")
d = int(a)
f = int(b)
c = int(c)
if (d+f) == c:
    print("YES")
else:
    print("NO")

C++ Code:

// AUTHOR - MALAY ZALAWADIA
// DATE - 28-01-2022
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define fl(i,n) for(ll i=0;i<n;i++)
#define fll(i,n,m) for(ll i=n;i<=m;i++)
#define rl(i,n,m) for(ll i=n;i>=m;i--)
#define py cout<<"YES"<< endl;
#define pn cout<<"NO"<< endl;
#define pi 3.141592653589793238
#define vr(v) v.begin(),v.end()
#define rv(v) v.end(),v.begin()
#define Code ios_base::sync_with_stdio(false);
#define By cin.tie(NULL);
#define MMZ cout.tie(NULL);
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
ll lcm(ll a, ll b){return (a/gcd(a,b)*b);}
string decToBinary(int n){string s="";int i = 0;while (n > 0) {s =to_string(n % 2)+s;n = n / 2;i++;}return s;}
ll binaryToDecimal(string n){string num = n;ll dec_value = 0;int base = 1;int len = num.length();for(int i = len - 1; i >= 0; i--){if (num[i] == '1')dec_value += base;base = base * 2;}return dec_value;}
bool isPrime(ll n){if(n<=1)return false;if(n<=3)return true;if(n%2==0||n%3==0)return false;for(int i=5;i*i<=n;i=i+6)if(n%i==0||n%(i+2)==0)return false;return true;}
bool nextPrime(ll N){if (N <= 1)return 2;ll prime = N;bool found = false;while (!found) {prime++;if (isPrime(prime)) found = true;}return prime;}
bool isPowerOfTwo(int n){if(n==0)return false;return (ceil(log2(n)) == floor(log2(n)));}
bool isPerfectSquare(ll x){if (x >= 0) {ll sr = sqrt(x);return (sr * sr == x);}return false;}
ll moduloMultiplication(ll a,ll b,ll mod){ll res = 0;a %= mod;while (b){if (b & 1)res = (res + a) % mod;b >>= 1;}return res;}
ll powermod(ll x, ll y, ll p){ll res = 1;x = x % p;if (x == 0) return 0;while (y > 0){if (y & 1)res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}

int NoZero(ll n) {
    vector<ll> v;
    while(n) {
        if(n%10 == 0) {
            n /= 10;
        }
        else {
            v.pb(n%10);
            n /= 10;
        }
    }

    ll num = 0;
    rl(i,v.size() - 1,0) {
        num = num*10 + v[i];
    }

    return num;
}

int main() {
    Code By MMZ
    /*ll t;
    cin>>t;
    while(t--) {
      mmz();
    }*/
    //mmz();
    ll a,b;

    while(cin >> a >> b) {
        if(NoZero(a) + NoZero(b) == NoZero(a+b)) py
        else pn
    }
}


Comments

Submit
0 Comments
More Questions

2099. Find Subsequence of Length K With the Largest Sum
1608A - Find Array
416. Partition Equal Subset Sum
1446. Consecutive Characters
1618A - Polycarp and Sums of Subsequences
1618B - Missing Bigram
938. Range Sum of BST
147. Insertion Sort List
310. Minimum Height Trees
2110. Number of Smooth Descent Periods of a Stock
2109. Adding Spaces to a String
2108. Find First Palindromic String in the Array
394. Decode String
902. Numbers At Most N Given Digit Set
221. Maximal Square
1200. Minimum Absolute Difference
1619B - Squares and Cubes
1619A - Square String
1629B - GCD Arrays
1629A - Download More RAM
1629C - Meximum Array
1629D - Peculiar Movie Preferences
1629E - Grid Xor
1629F1 - Game on Sum (Easy Version)
2148. Count Elements With Strictly Smaller and Greater Elements
2149. Rearrange Array Elements by Sign
2150. Find All Lonely Numbers in the Array
2151. Maximum Good People Based on Statements
2144. Minimum Cost of Buying Candies With Discount
Non empty subsets